package edu.johnpank.libassistant.repo

import edu.johnpank.libassistant.entity.BorrowedBook
import org.springframework.data.repository.CrudRepository
import org.springframework.stereotype.Repository
import java.util.Optional

@Repository
interface BorrowedBookRepository: CrudRepository<BorrowedBook?, Long> {

    override fun findAll(): MutableList<BorrowedBook>

    fun findAllByReaderId(readerId: Long): MutableList<BorrowedBook>

    fun findAllByReaderIdAndReturned(readerId: Long, returned: Boolean): MutableList<BorrowedBook>

    fun findAllByBookIdAndReturned(bookId: Long, returned: Boolean): MutableList<BorrowedBook>

    fun findByReaderIdAndBookIdAndReturned(readerId: Long, bookId: Long, returned: Boolean): Optional<BorrowedBook>

}